package com.sec.android.app.myfiles.facade.cmd;

import com.sec.android.app.myfiles.info.AppConstants;
import com.sec.android.app.myfiles.log.Log;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.module.trash.TrashFileRecord;
import com.sec.android.app.myfiles.navigation.NavigationInfo;
import com.sec.android.app.myfiles.navigation.NavigationManager;

import org.puremvc.java.multicore.interfaces.INotification;
import org.puremvc.java.multicore.patterns.command.SimpleCommand;

/**
 * Created by gw8951.kim on 2016-11-10.
 */

public class GoTrashCmd extends SimpleCommand {

    @Override
    public void execute(INotification notification) {
        Object[] params = (Object[]) notification.getBody();
        int processId = (int) params[0];

        NavigationManager navigationMgr = NavigationManager.getInstance(processId);
        NavigationInfo curInfo = navigationMgr.getCurInfo();
        FileRecord record;
        NavigationInfo info;
        if (curInfo != null) {
            FileRecord curRecord = curInfo.getCurRecord();
            record = new TrashFileRecord(FileRecord.StorageType.Trash, AppConstants.StoragePath.SAMSUNG_DRIVE_TRASH_FILES, curRecord);
            info = NavigationInfo.getInstance(curInfo, record);
        } else {
            Log.i(this, "execute() - curInfo is null");
            record = FileRecord.createFileRecord(FileRecord.StorageType.Trash, AppConstants.StoragePath.SAMSUNG_DRIVE_TRASH_FILES);
            info = NavigationInfo.getInstance(NavigationInfo.NavigationMode.Normal, record);
        }

        navigationMgr.enter(info);
    }
}
